package com.bdzl.api.service;

import com.bdzl.api.util.QCloudOCRUtil;
import com.bdzl.pub.entity.data.UserInfoDO;
import com.qcloud.image.exception.AbstractImageException;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class QCloudOCRService {

    public UserInfoDO getIdCardInfo(String url,int type) throws AbstractImageException {
        UserInfoDO userInfoDO = new UserInfoDO();
        String[] urls = new String[]{url};
        List<UserInfoDO> idDos = new ArrayList<>();
        QCloudOCRUtil.getIDDos(urls,type,idDos);
        if (CollectionUtils.isNotEmpty(idDos)){
            userInfoDO = idDos.get(0);
        }
        return userInfoDO;
    }
}
